package com.xiongwei.singleton;

import java.awt.image.VolatileImage;

/**
 * 懒汉式（双重检查） 推荐使用
 */
public class LazyMan4 {
    private static volatile LazyMan4 instance;

    private LazyMan4() {
        System.out.println("懒汉式（双重检查）");
    }

    public static LazyMan4 getInstance() {
        if(instance == null) {
            synchronized (LazyMan4.class) {
                if (instance == null) {
                    instance = new LazyMan4();
                }
            }
        }
        return instance;
    }
}
